Search Results

Search found 13 results on 1 pages for 'rspec2'.

Page 1/1 | 1 

  • How to create a subject helper method in Rspec2

    - by Hedgehog
    In rpsec 2.12 I expected this helper method definition to work: module X private def build_them(type) puts 'Catching the star' end end context 'public/private instance methods' do subject{ Class.new { extend(::X) } } def subject.build(type) puts "Throwing a star" build_them(type) end it{ should respond_to :build} end The actual result is a failed spec: expected #<Class:0x00000002ea5f90> to respond to :build I expected the example to pass Any suggestions on how to do this correctly?

    Read the article

  • Test flash notice in layout view spec (rspec2, rails3)

    - by jbpros
    Hi! I'd like to spec the fact that my application layout view prints out flash notices. However the following code does not run, the flash method does not exist in view specs (as opposed to controller specs where it works perfectly): describe 'layouts/application' do it "renders flash notices" do flash[:notice] = "This is a notice!" render response.should contain "This is a notice!" end end Is my code wrong or is it a "not-yet-implemented feature" in Rspec 2? I'm on Rails3 and Rspec2 from its master branch on Git. Thanks!

    Read the article

  • shoulda macros with rspec2 beta 5 and rails3 beta2

    - by Millisami
    I've setup Rspec2 beta5 and shoulda as following to use shoulda macros inside rspec model tests. Gemfile group :test do gem "rspec", ">= 2.0.0.beta.4" gem "rspec-rails", ">= 2.0.0.beta.4" gem 'shoulda', :git => 'git://github.com/bmaddy/ shoulda.git' gem "faker" gem "machinist" gem "pickle", :git => 'git://github.com/codegram/ pickle.git' gem 'capybara', :git => 'git://github.com/jnicklas/ capybara.git' gem 'database_cleaner', :git => 'git://github.com/bmabey/ database_cleaner.git' gem 'cucumber-rails', :git => 'git://github.com/aslakhellesoy/ cucumber-rails.git' end *spec_helper.rb* Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} require 'shoulda' Rspec.configure do |config| *spec/models/outlet_spec.rb* require 'spec_helper' describe Outlet do it { should validate_presence_of(:name) } end And when I run the spec, I get the following error. [~/rails_apps/rails3_apps/automation (master)?] ? spec spec/models/ outlet_spec.rb DEPRECATION WARNING: RAILS_ROOT is deprecated! Use Rails.root instead. (called from join at /home/millisami/.rvm/gems/ruby-1.9.1-p378%rails3/ bundler/gems/shoulda-87e75311f83548760114cd4188afa4f83fecdc22-master/ lib/shoulda/autoload_macros.rb:40) F 1) Outlet Failure/Error: it { should validate_presence_of(:name) } undefined method `validate_presence_of' for #<Rspec::Core::ExampleGroup::Nested_1:0xc4dc138 @__memoized={}> # ./spec/models/outlet_spec.rb:4:in `block (2 levels) in <top (required)>' Finished in 0.0399 seconds 1 example, 1 failures [~/rails_apps/rails3_apps/automation (master)?] ? Why the "undefined method" ?? Is the shoulda getting loaded?

    Read the article

  • Rspec2, Rails3, Authlogic: Can't run specs

    - by Sam
    When I do rspec spec in my rails project, I get No examples were matched. Perhaps {:if=>#<Proc:0x0000010126e998@/Users/samliu/.rvm/gems/ruby-1.9.2-p0@rails3/gems/rspec-core-2.3.1/lib/rspec/core/configuration.rb:50 (lambda)>, :unless=>#<Proc:0x0000010126e970@/Users/samliu/.rvm/gems/ruby-1.9.2-p0@rails3/gems/rspec-core-2.3.1/lib/rspec/core/configuration.rb:51 (lambda)>} is excluding everything? Finished in 0.00004 seconds 0 examples, 0 failures Now, this seems like maybe if I wrote a spec it would work, but as soon as I write a spec (and I do include spec_helper) /Users/samliu/.rvm/gems/ruby-1.9.2-p0@rails3/gems/rspec-core-2.3.1/lib/rspec/core/backward_compatibility.rb:20:in `const_missing': uninitialized constant Authlogic (NameError) from /{myapp}/app/models/user_session.rb:1:in `<top (required)>' from /Users/samliu/.rvm/gems/ruby-1.9.2-p0@rails3/gems/railties-3.0.3/lib/rails/engine.rb:138:in `block (2 levels) in eager_load!' from /Users/samliu/.rvm/gems/ruby-1.9.2-p0@rails3/gems/railties-3.0.3/lib/rails/engine.rb:137:in `each' from /Users/samliu/.rvm/gems/ruby-1.9.2-p0@rails3/gems/railties-3.0.3/lib/rails/engine.rb:137:in `block in eager_load!' from /Users/samliu/.rvm/gems/ruby-1.9.2-p0@rails3/gems/railties-3.0.3/lib/rails/engine.rb:135:in `each' from /Users/samliu/.rvm/gems/ruby-1.9.2-p0@rails3/gems/railties-3.0.3/lib/rails/engine.rb:135:in `eager_load!' from /Users/samliu/.rvm/gems/ruby-1.9.2-p0@rails3/gems/railties-3.0.3/lib/rails/application.rb:108:in `eager_load!' from /Users/samliu/.rvm/gems/ruby-1.9.2-p0@rails3/gems/railties-3.0.3/lib/rails/application/finisher.rb:41:in `block in <module:Finisher>' from /Users/samliu/.rvm/gems/ruby-1.9.2-p0@rails3/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `instance_exec' from /Users/samliu/.rvm/gems/ruby-1.9.2-p0@rails3/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `run' from /Users/samliu/.rvm/gems/ruby-1.9.2-p0@rails3/gems/railties-3.0.3/lib/rails/initializable.rb:50:in `block in run_initializers' from /Users/samliu/.rvm/gems/ruby-1.9.2-p0@rails3/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `each' from /Users/samliu/.rvm/gems/ruby-1.9.2-p0@rails3/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `run_initializers' from /Users/samliu/.rvm/gems/ruby-1.9.2-p0@rails3/gems/railties-3.0.3/lib/rails/application.rb:134:in `initialize!' from /Users/samliu/.rvm/gems/ruby-1.9.2-p0@rails3/gems/railties-3.0.3/lib/rails/application.rb:77:in `method_missing' from /{myapp}/config/environment.rb:5:in `<top (required)>' from <internal:lib/rubygems/custom_require>:29:in `require' from <internal:lib/rubygems/custom_require>:29:in `require' from /{myapp}/spec/spec_helper.rb:3:in `<top (required)>' from <internal:lib/rubygems/custom_require>:29:in `require' from <internal:lib/rubygems/custom_require>:29:in `require' from /{myapp}/spec/controllers/pages_controller_spec.rb:1:in `<top (required)>' from /Users/samliu/.rvm/gems/ruby-1.9.2-p0@rails3/gems/rspec-core-2.3.1/lib/rspec/core/configuration.rb:388:in `load' from /Users/samliu/.rvm/gems/ruby-1.9.2-p0@rails3/gems/rspec-core-2.3.1/lib/rspec/core/configuration.rb:388:in `block in load_spec_files' from /Users/samliu/.rvm/gems/ruby-1.9.2-p0@rails3/gems/rspec-core-2.3.1/lib/rspec/core/configuration.rb:388:in `map' from /Users/samliu/.rvm/gems/ruby-1.9.2-p0@rails3/gems/rspec-core-2.3.1/lib/rspec/core/configuration.rb:388:in `load_spec_files' from /Users/samliu/.rvm/gems/ruby-1.9.2-p0@rails3/gems/rspec-core-2.3.1/lib/rspec/core/command_line.rb:18:in `run' from /Users/samliu/.rvm/gems/ruby-1.9.2-p0@rails3/gems/rspec-core-2.3.1/lib/rspec/core/runner.rb:55:in `run_in_process' from /Users/samliu/.rvm/gems/ruby-1.9.2-p0@rails3/gems/rspec-core-2.3.1/lib/rspec/core/runner.rb:46:in `run' from /Users/samliu/.rvm/gems/ruby-1.9.2-p0@rails3/gems/rspec-core-2.3.1/lib/rspec/core/runner.rb:10:in `block in autorun' The important line here seems to be /core/backward_compatibility.rb:20:in `const_missing': uninitialized constant Authlogic (NameError) Now if this were rails 2.3.8, I'd simply put config.gem "authlogic" into the environment.rb, in the initialization code block. However, the rails 3 environment.rb looks way different (there is no config code block, so putting it in arbitrarily causes an error where config is not defined). So my questions are 1) Do I actually have to put the gem config anywhere? I looked at https://github.com/trevmex/authlogic_rails3_example/ and it seems he didn't put it anywhere. 2) Does anyone know what I'm doing wrong in terms of rspec? My gem list is *** LOCAL GEMS *** abstract (1.0.0) actionmailer (3.0.3, 3.0.1, 3.0.0, 3.0.0.rc2, 2.3.4) actionpack (3.0.3, 3.0.1, 3.0.0, 3.0.0.rc2, 2.3.4) activemodel (3.0.3, 3.0.1, 3.0.0, 3.0.0.rc2) activerecord (3.0.3, 3.0.1, 3.0.0, 3.0.0.rc2, 2.3.4) activeresource (3.0.3, 3.0.1, 3.0.0, 3.0.0.rc2, 2.3.4) activesupport (3.0.3, 3.0.1, 3.0.0, 3.0.0.rc2, 2.3.4) arel (2.0.6, 1.0.1) asdf (0.5.0) authlogic (2.1.6, 2.1.3) autotest (4.4.6, 4.4.1) autotest-fsevent (0.2.4) autotest-growl (0.2.9) autotest-rails (4.1.0) autotest-rails-pure (4.1.2) bluecloth (2.0.9) builder (2.1.2) bundler (1.0.7, 1.0.2) cgi_multipart_eof_fix (2.5.0) commonwatir (1.6.2) couchrest (0.33) cri (1.0.1) cucumber (0.4.4, 0.4.3, 0.3.11) daemons (1.1.0, 1.0.10) dependencies (0.0.7) diff-lcs (1.1.2) erubis (2.6.6) fastercsv (1.5.0) fastthread (1.0.7) firewatir (1.6.2) flay (1.4.0) flog (2.2.0) funfx (0.2.2) gem_plugin (0.2.3) gemsonrails (0.7.2) giraffesoft-resource_controller (0.6.5) haml (2.2.14) hoe (2.3.3) i18n (0.4.1) jscruggs-metric_fu (1.1.5) json_pure (1.1.9) kramdown (0.12.0) mail (2.2.13, 2.2.6.1) memcache-client (1.8.5) mime-types (1.16) mojombo-chronic (0.3.0) mongrel (1.1.5) monk (0.0.7) nanoc (3.1.5) nanoc3 (3.1.5) nokogiri (1.4.3.1, 1.4.0) open4 (0.9.6) polyglot (0.3.1, 0.2.9) rack (1.2.1, 1.0.1) rack-mount (0.6.13) rack-test (0.5.6) rails (3.0.0, 2.3.4) rails3-generators (0.17.0, 0.14.0) railties (3.0.3, 3.0.1, 3.0.0, 3.0.0.rc2) rake (0.8.7) relevance-rcov (0.9.2.1) rest-client (1.0.3) rspec (2.3.0, 2.0.0.rc, 1.2.9) rspec-core (2.3.1, 2.0.0.rc) rspec-expectations (2.3.0, 2.0.0.rc) rspec-mocks (2.3.0, 2.0.0.rc) rspec-rails (2.3.1, 2.0.0.rc, 1.2.9) ruby_parser (2.0.4) rubyforge (2.0.3) rubygems-update (1.3.6, 1.3.5) rvm (1.0.13) s4t-utils (1.0.4) safariwatir (0.3.7) sexp_processor (3.0.3) spork (0.7.3) sqlite3-ruby (1.3.1, 1.2.5) sys-uname (0.8.5) term-ansicolor (1.0.4) text-format (1.0.0) text-hyphen (1.0.0) thor (0.14.6, 0.14.3, 0.12.0) treetop (1.4.8, 1.4.2) tzinfo (0.3.23) user-choices (1.1.6) vlad (2.0.0) vlad-git (2.1.0) webrat (0.7.1, 0.6.0, 0.5.3) xml-simple (1.0.12) ZenTest (4.4.2) I am using ruby 1.9.2 and rails 3.0.3 installed using RVM on OSX 10.6 Snow Leopard. I just want to be able to run my specs like I used to. As a separate issue, autotest yields an error about an include for autotest/growl but I installed autotest-growl. Maybe this is a gem issue? I tried doing the same things and get the same error when it comes to using my ubuntu 10.04 server machine though. Gemfile source 'http://rubygems.org' gem 'rails', '3.0.3' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'sqlite3-ruby', :require => 'sqlite3' group :couch do gem 'couchrest' end group :user_auth do gem 'authlogic' gem "rails3-generators" gem 'facebooker' end group :markup do gem 'haml' gem 'sass' end group :testing do gem 'rspec-rails' gem 'rspec' gem 'webrat' gem 'cucumber' gem 'capybara' gem 'factory_girl' gem 'shoulda' gem 'autotest' end group :server do gem 'unicorn' end # Use unicorn as the web server # gem 'unicorn' # Deploy with Capistrano # gem 'capistrano' # To use debugger # gem 'ruby-debug' # Bundle the extra gems: # gem 'bj' # gem 'nokogiri' # gem 'sqlite3-ruby', :require => 'sqlite3' # gem 'aws-s3', :require => 'aws/s3' # Bundle gems for the local environment. Make sure to # put test-only gems in this group so their generators # and rake tasks are available in development mode: # group :development, :test do # gem 'webrat' # end Gemfile.lock GEM remote: http://rubygems.org/ specs: ZenTest (4.4.2) abstract (1.0.0) actionmailer (3.0.3) actionpack (= 3.0.3) mail (~> 2.2.9) actionpack (3.0.3) activemodel (= 3.0.3) activesupport (= 3.0.3) builder (~> 2.1.2) erubis (~> 2.6.6) i18n (~> 0.4) rack (~> 1.2.1) rack-mount (~> 0.6.13) rack-test (~> 0.5.6) tzinfo (~> 0.3.23) activemodel (3.0.3) activesupport (= 3.0.3) builder (~> 2.1.2) i18n (~> 0.4) activerecord (3.0.3) activemodel (= 3.0.3) activesupport (= 3.0.3) arel (~> 2.0.2) tzinfo (~> 0.3.23) activeresource (3.0.3) activemodel (= 3.0.3) activesupport (= 3.0.3) activesupport (3.0.3) arel (2.0.6) authlogic (2.1.6) activesupport autotest (4.4.6) ZenTest (>= 4.4.1) builder (2.1.2) capybara (0.4.0) celerity (>= 0.7.9) culerity (>= 0.2.4) mime-types (>= 1.16) nokogiri (>= 1.3.3) rack (>= 1.0.0) rack-test (>= 0.5.4) selenium-webdriver (>= 0.0.27) xpath (~> 0.1.2) celerity (0.8.6) childprocess (0.1.6) ffi (~> 0.6.3) couchrest (1.0.1) json (>= 1.4.6) mime-types (>= 1.15) rest-client (>= 1.5.1) cucumber (0.10.0) builder (>= 2.1.2) diff-lcs (~> 1.1.2) gherkin (~> 2.3.2) json (~> 1.4.6) term-ansicolor (~> 1.0.5) culerity (0.2.13) diff-lcs (1.1.2) erubis (2.6.6) abstract (>= 1.0.0) facebooker (1.0.75) json_pure (>= 1.0.0) factory_girl (1.3.2) ffi (0.6.3) rake (>= 0.8.7) gherkin (2.3.2) json (~> 1.4.6) term-ansicolor (~> 1.0.5) haml (3.0.25) i18n (0.5.0) json (1.4.6) json_pure (1.4.6) kgio (2.0.0) mail (2.2.13) activesupport (>= 2.3.6) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) mime-types (1.16) nokogiri (1.4.4) polyglot (0.3.1) rack (1.2.1) rack-mount (0.6.13) rack (>= 1.0.0) rack-test (0.5.6) rack (>= 1.0) rails (3.0.3) actionmailer (= 3.0.3) actionpack (= 3.0.3) activerecord (= 3.0.3) activeresource (= 3.0.3) activesupport (= 3.0.3) bundler (~> 1.0) railties (= 3.0.3) rails3-generators (0.17.0) railties (>= 3.0.0) railties (3.0.3) actionpack (= 3.0.3) activesupport (= 3.0.3) rake (>= 0.8.7) thor (~> 0.14.4) rake (0.8.7) rest-client (1.6.1) mime-types (>= 1.16) rspec (2.3.0) rspec-core (~> 2.3.0) rspec-expectations (~> 2.3.0) rspec-mocks (~> 2.3.0) rspec-core (2.3.1) rspec-expectations (2.3.0) diff-lcs (~> 1.1.2) rspec-mocks (2.3.0) rspec-rails (2.3.1) actionpack (~> 3.0) activesupport (~> 3.0) railties (~> 3.0) rspec (~> 2.3.0) rubyzip (0.9.4) sass (3.1.0.alpha.206) selenium-webdriver (0.1.2) childprocess (~> 0.1.5) ffi (~> 0.6.3) json_pure rubyzip shoulda (2.11.3) sqlite3-ruby (1.3.2) term-ansicolor (1.0.5) thor (0.14.6) treetop (1.4.9) polyglot (>= 0.3.1) tzinfo (0.3.23) unicorn (3.1.0) kgio (~> 2.0.0) rack webrat (0.7.2) nokogiri (>= 1.2.0) rack (>= 1.0) rack-test (>= 0.5.3) xpath (0.1.2) nokogiri (~> 1.3) PLATFORMS ruby DEPENDENCIES authlogic autotest capybara couchrest cucumber facebooker factory_girl haml rails (= 3.0.3) rails3-generators rspec rspec-rails sass shoulda sqlite3-ruby unicorn webrat

    Read the article

  • Arbitrary attributes error with has_one association and Factory Girl

    - by purpletonic
    I'm trying to build a basic shopping cart for a Rails app I'm working on. Nothing special, - the shopping cart has many line_items - each line_item has_one product associated and a quantity with it class Cart < ActiveRecord::Base attr_accessible :line_items has_many :line_items, :dependent => :destroy end class LineItem < ActiveRecord::Base attr_accessible :quantity, :product belongs_to :cart has_one :product end I'm trying to use RSpec to test this association, but i'm doing something wrong as I'm getting an error that says: DEPRECATION WARNING: You're trying to create an attribute 'line_item_id'. Writing arbitrary attributes on a model is deprecated, and I'm not sure why. In my factories.rb file I'm defining the line_item factory as follows: factory :line_item do quantity { Random.rand(1..5) } product end factory :cart do factory :cart_with_two_line_items do ignore do line_item_count 2 end after(:create) do |cart, evaluator| FactoryGirl.create_list(:line_item, evaluator.line_item_count, cart_id: cart) end end end Any pointers where I'm going wrong, it's probably something basic, but I'm still quite new to Rspec. Thanks in advance.

    Read the article

  • how to tell Rails RSpec that spec is "type helper"

    - by equivalent8
    I wrote *simple_form* input extension that is located in app/inputs/something_input.rb I'm trying to write RSpec for this. When I put this spec inside spec/helpers/application_helper_spec.rb everything was working without single problem. # spec/helpers/application_helper_spec.rb require 'spec_helper' describe ApplicationHelper do it do helper.simple_form_for @foo,:method=>'get', :url=>helper.users_path do |f| f.input :created_at, :as =>:custom_datepicker end.should =~ /something/ end end Now I'm trying to move that spec to spec/inputs/something_input_spec.rb so it will be similar name path. # spec/imputs/something_input_spec.rb require 'spec_helper' describe SomethingInput do it do helper.simple_form_for @foo,:method=>'get', :url=>helper.users_path do |f| f.input :created_at, :as =>:custom_datepicker end.should =~ /something/ end end # #ERROR: undefined local variable or method `helper' for #<RSpec::Core::ExampleGroup the thing I want to tell RSpec to threat this file as type helper spec, so I will have helper method availible with all the RSpec::Rails::HelperExampleGroup functionality ... how can I do that ?? I was trying to extend/include it with RSpec::Rails::HelperExampleGroup nothing seems to work

    Read the article

  • How do I configure integration tests using rspec 2?

    - by Jamie Monserrate
    I need to have different settings for my unit tests and different settings for my integration tests. Example For unit tests, I would like to do WebMock.disable_net_connect!(:allow_localhost => true) And for integration tests, I would like to do WebMock.allow_net_connect! Also, before the start of an integration test, I would like to make sure that solr is started. Hence I want to be able to call config.before(:suite) do SunspotStarter.start end BUT, only for integration tests. I do not want to start my solr if its a unit test. How do I keep their configurations separate? Right now, I have solved this by keeping my integration tests in a folder outside the spec folder, which has its own spec_helper. Is there any better way?

    Read the article

  • disabling transactional fixtures in Rspec has no effect

    - by Dia
    Due to a legacy database I'm using, I'm stuck with MySQL using MyISAM, which means my tables don't support transactions. This is causing the tests to fail, since table data generated (I'm using factory_girl for fixtures) by the tests are not reverted for each scenario. I discovered that Rspec exposes the config.use_transactional_fixtures config setting in spec_helper.rb. which is set to true by default. When I set it to false, I don't see any effect on my tests; they still fail due to duplicate records. Isn't that setting supposed to automatically unroll any changes made to the DB? Or am I supposed to do that manually?

    Read the article

  • Examine one particular call and ignore the rest

    - by lulalala
    I have a Currency class and want to update its rates. The following is the spec of an update class I plan to write: describe WebCrawlers::Currency::FeedParser do let(:gbp){ double('GBP').as_null_object } let(:usd){ double('USD').as_null_object } describe '#perform' do before do Currency.stub(:find_by_name).with('GBP').and_return( gbp ) Currency.stub(:find_by_name).with('USD').and_return( usd ) end it 'should update GBP rate' do gbp.should_receive(:update_attributes).with(rate_to_usd:0.63114) subject.perform end it 'should not update USD rate' do usd.should_not_receive(:update_attributes) subject.perform end end end and it works find if I only update GBP in my actual class: class WebCrawlers::Currency::FeedParser def perform Currency.find_by_name('GBP').update_attributes(rate_to_usd: 0.63114) end end However once I start updating other currencies like 'CAD', Rspec complains <Currency> received :find_by_name with unexpected arguments expected: ("USD") got: ("CAD") Why is this the case? Instead of NOT expecting USD, it says it is. And in the future there will be lots of currencies to update, but I don't want to test and stub each one of them. How can I resolve this issue?

    Read the article

  • Rspec and Rails 3 - Problem Validating Nested Attribute Collection Size

    - by MunkiPhD
    When I create my Rspec tests, I keep getting a validation of false as opposed to true for the following tests. I've tried everything and the following is the measly code that I have now - so if it's waaaaay wrong, that's why. class Master < ActiveRecord::Base attr_accessible :name, :specific_size # Associations ---------------------- has_many :line_items accepts_nested_attributes_for :line_items, :allow_destroy => true, :reject_if => lambda { |a| a[:item_id].blank? } # Validations ----------------------- validates :name, :presence => true, :length => {:minimum => 3, :maximum => 30} validates :specific_size, :presence => true, :length => {:minimum => 4, :maximum => 30} validate :verify_items_count def verify_items_count if self.line_items.size < 2 errors.add(:base, "Not enough items to create a master") end end end And here it the items model: class LineItem < ActiveRecord::Base attr_accessible :specific_size, :other_item_type_id # Validations -------------------- validates :other_item_type_id, :presence => true validates :master_id, :presence => true validates :specific_size, :presence => true # Associations --------------------- belongs_to :other_item_type belongs_to :master end The RSpec Tests: before(:each) do @master_lines = [] @master_lines << LineItem.new(:other_item_type_id => 1, :master_id => 2, :specific_size => 1) @master_lines << LineItem.new(:other_item_type_id => 2, :master_id => 2, :specific_size => 1) @attr = {:name => "Some Master", :specific_size => "1 giga"} end it "should create a new instance given a valid name and specific size" do @master = Master.create(@attr) line_item_one = @master.line_items.build(:other_item_type_id => 1, :specific_size => 1) line_item_two = @master.line_items.build(:other_item_type_id => 2, :specific_size => 2) @master.line_items.size === 2 @master.should be_valid end it "should have at least two items to be valid" do master = Master.new(:name => "test name", :specific_size => "1 mega") master_item_one = LineItem.new(:other_item_type_id => 1, :specific_size => 2) master_item_two = LineItem.new(:other_item_type_id => 2, :specific_size => 1) master.line_items << master_item_one master.should_not be_valid master.line_items << master_item_two master.line_items.size.should === 2 master.should be_valid end I'm very new to Rspec and Rails - and I've been failing at this for the past couple of hours. Thanks for any help in advance.

    Read the article

  • session variable not available in global before(:each, :type => :controller)

    - by Rob
    Hi, I'm refactoring some specs, in controller specs I have a before(:each) which sets up things required in the session my before filter is... config.before(:each, :type => :controller) do ... session[:current_user] = @user session[:instance] = @instance ... end @user and @instance are also set in the before(:each) i've just hidden them for readability here I get the following error when running the controller tests undefined method `session' for nil:NilClass I would expect the global before callbacks to have the same things as the ones in the individual tests but I guess maybe they are loaded before the rails environment has been initialised? Thanks

    Read the article

  • Mocking view helpers with rspec-rails 2.0.0.beta.8

    - by snl
    I am trying to mock a view helper with rspec2. The old way of doing this throws an error, complaining the template object is not defined: template.should_receive(:current_user).and_return(mock("user")) Am I missing something here, or is this not implemented in rspec2 (yet)?

    Read the article

  • RCov with RSpec-2

    - by JoshReedSchramm
    I'm working with a bit of a bleeding edge rails app. Rails 3, RSpec 2, Rspec-Rails2. It seems as if RSpec2 doesn't include the spec:rcov rake task that RSpec 1 has. (at least it isn't there yet) Has anyone had any luck running rcov with rspec 2, or writing their own rake task to make this work?

    Read the article

1