rspec2

render_views returning NoMethodError

强颜欢笑 提交于 2019-12-08 04:38:31
I'm currently going through the Ruby on Rails Tutorial by Michael Hartl, and in Section 3.2.2 of the tutorial, he talks about using RSpec to test for the titles of the page. My tests (which I wrote myself, following his tutorial) kept failing the title tests (it can find the tag, but the title is always a blank string), and some searching on Google told me I needed to include the function render_views to pass the tests. My problem is that no matter what I try, RSpec returns a NoMethodError for render_views . The things I've tried: config.render_views in spec_helper.rb describe "Static Pages"

RubyTest with SublimeText 2 [duplicate]

ⅰ亾dé卋堺 提交于 2019-12-08 04:12:50
问题 This question already has answers here : RubyTest in Sublime Text 2 (13 answers) Closed 6 years ago . I'm using Sublime Text 2 and installed the RubyTest package. I'm trying to run a test using Command-Shift-R. I also use rbenv for ruby and have installed gems using Bundler. The output is: /bin/sh: rspec: command not found The console shows the following command was run: cd '/Users/user/Dropbox/code/app/' && rspec spec/controllers/profile_controller_spec.rb -l 163 When I run that command in

RSpec should_receive macro that includes id of what needs to be tested

本秂侑毒 提交于 2019-12-07 18:06:55
问题 How can I write this so it passes without hardcoding 1 . Chicken and the egg. @sender = Factory(:user) @receiver = Factory(:user) mailer = double mailer.should_receive(:deliver) Mailer.should_receive(:email).with(1, @sender.id, @receiver.id).and_return(mailer) # This will create an object with id #1 to make this test pass @object = Object.create(:sender => @sender, :receiver => @receiver) 回答1: How about this? Mailer.should_receive(:email).with(an_instance_of(Fixnum), @sender.id, @receiver.id)

How do I define sequences in FactoryGirlRails?

痞子三分冷 提交于 2019-12-07 16:28:50
问题 Previously in Factory girl, we could define sequences like so: # /spec/factories.rb FactoryGirl.define do # this is the sequence in question: sequence(:random_token) { Digest::MD5.hexdigest(rand.to_s) } factory :story do sequence(:title) { |n| "My Cool Story##{n}" } # Call the sequence here: token { Factory.next(:random_token) } description { "#{title} description"} end end Now, when I try that approach - I get a deprecation warning telling me: WARNING: FactoryGirl::Sequence#next is

rails3 rspec issue

不羁的心 提交于 2019-12-07 15:39:47
问题 I am trying out rails3. I am using railstutorial site to explore more about rails3; the tutorial is very good to begin with (I have minimal experience with rails2). I have an issue with rspec which is currently blocking my progress. I saw that the tutorial recommended using rspec2.0.0.beta.18 gem; I instead installed rspec2.0.0.beta.20 gem using bundle install However I find issues with this version of rspec My rspec for integration_test looks like: describe "LayoutLinks" do it "should have a

RubyTest with SublimeText 2 [duplicate]

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-07 09:17:27
This question already has answers here : RubyTest in Sublime Text 2 (13 answers) Closed 6 years ago . I'm using Sublime Text 2 and installed the RubyTest package. I'm trying to run a test using Command-Shift-R. I also use rbenv for ruby and have installed gems using Bundler. The output is: /bin/sh: rspec: command not found The console shows the following command was run: cd '/Users/user/Dropbox/code/app/' && rspec spec/controllers/profile_controller_spec.rb -l 163 When I run that command in Terminal, it works fine. Any why it wouldn't work in Sublime? How are you starting the sublime?

rspec user test gives “undefined local variable or method `confirmed_at' ”

不问归期 提交于 2019-12-07 06:25:44
问题 my rspec test is giving me NameError: undefined local variable or method `confirmed_at' for #<User:0xca6ff98> My User spec is: require 'spec_helper' describe User do before(:each) do @user = Factory(:user) end # Factory will make sure that in the future if attributes are added the tests below don't break # Just as long as the Factory is updated for the new attributes as appropriate. context "email is null" do it "record is invalid " do @user.name = nil @user.should_not be_valid end end

Ruby 1.9.3-p0 and RSpec causes frequent segmentation faults

余生颓废 提交于 2019-12-07 03:28:51
问题 Is it just me, or has Ruby 1.9.3 introduced frequent segmentation faults when running RSpec? Since upgrading to 1.9.3, I find startup time is noticeably quicker, however I get segmentation faults when running RSpec around 50% of the time. The output that I am getting from Ruby is at http://pastebin.com/89YmpzaJ and my Gemfile is at http://pastebin.com/L6r73Max Does anyone know what could be causing this? I am seeing this problem on both my CI server and my local development machine. 回答1:

Rspec2 testing a before_validation method

风流意气都作罢 提交于 2019-12-07 00:04:06
问题 I have the following to remove the spaces on a specific attribute. #before_validation :strip_whitespace protected def strip_whitespace self.title = self.title.strip end And I want to test it. For now, I've tried: it "shouldn't create a new part with title beggining with space" do @part = Part.new(@attr.merge(:title => " Test")) @part.title.should.eql?("Test") end What am I missing? 回答1: Validations won't run until the object is saved, or you invoke valid? manually. Your before_validation

RSpec response.body is still empty even with config.render_views

别说谁变了你拦得住时间么 提交于 2019-12-06 19:44:37
问题 In my spec_helper.rb file I have specifically set it to config.render_views but the response.body I get back is still empty. Here is my basic spec describe "#index" do it "should list all rooms" do get 'index' stub(Person).all end it "responds with 200 response code" do response.should be_ok end it "renders the index template" do pp response.body response.should render_template("people/index") end end Is there anything else that could have shorted this behavior? It's fine when I go through