Search Results

Search found 260 results on 11 pages for 'rspec'.

Page 6/11 | < Previous Page | 2 3 4 5 6 7 8 9 10 11  | Next Page >

  • How do I setup model associations in an RSpec test?

    - by Eric M.
    I've pastied the specs I've written for the posts/show.html.erb view in an application I'm writing as a means to learn RSpec. I am still learning about mocks and stubbing. This question is specific to the "should list all related comments" spec. What I want is to test that the show view displays a post's comments. But what I'm not sure about is how to setup this test and then have the test iterate through with should contain('xyz') statements. Any hints? Other suggestions are also appreciated! Thanks. ---Edit Some more information. I have a named_scope applied to comments in my view (I know, I did this a bit backwards in this case), so @post.comments.approved_is(true). The code pastied responds with the error "undefined method `approved_is' for #", which makes sense since I told it stub comments and return a comment. I'm still not sure, however, how to chain the stubs so that @post.comments.approved_is(true) will return an array of comments.

    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

  • Is it legal to stub the #class method of a Mock object when using RSpec in a Ruby on Rails applicati

    - by MiniQuark
    I would like to stub the #class method of a mock object: describe Letter do before(:each) do @john = mock("John") @john.stub!(:id).and_return(5) @john.stub!(:class).and_return(Person) # is this ok? @john.stub!(:name).and_return("John F.") Person.stub!(:find).and_return(@john) end it.should "have a valid #to field" do letter = Letter.create!(:to=>@john, :content => "Hello John") letter.to_type.should == @john.class.name letter.to_id.should == @john.id end [...] end On line 5 of this program, I stub the #class method, in order to allow things like @john.class.name. Is this the right way to go? Will there be any bad side effect? Edit: The Letter class looks like this: class Letter < ActiveRecord::Base belongs_to :to, :polymorphic => true [...] end I wonder whether ActiveRecord gets the :to field's class name with to.class.name or by some other means. Maybe this is what the class_name method is ActiveRecord::Base is for?

    Read the article

  • How to run only the latest/a given test using Rspec?

    - by marcgg
    Let's say I have a big spec file with 20 tests because I'm testing a large model and I had no other way of doing it : describe Blah it "should do X" do ... end it "should do Y" do ... end ... it "should do Z" do ... end end Running a single file is faster than running the whole test suite, but it's still pretty long. Is there a way to run the last one (ie the one at the end of the file, here "should do Z")? If this is not possible, is there a way to specify which test I want to run in my file ?

    Read the article

  • Using Rails and Rspec, how do you test that the database is not touched by a method

    - by Will Tomlins
    So I'm writing a test for a method which for performance reasons should achieve what it needs to achieve without using SQL queries. I'm thinking all I need to know is what to stub: describe SomeModel do describe 'a_getter_method' do it 'should not touch the database' do thing = SomeModel.create something_inside_rails.should_not_receive(:a_method_querying_the_database) thing.a_getter_method end end end EDIT: to provide a more specific example: class Publication << ActiveRecord::Base end class Book << Publication end class Magazine << Publication end class Student << ActiveRecord::Base has_many :publications def publications_of_type(type) #this is the method I am trying to test. #The test should show that when I do the following, the database is queried. self.publications.find_all_by_type(type) end end describe Student do describe "publications_of_type" do it 'should not touch the database' do Student.create() student = Student.first(:include => :publications) #the publications relationship is already loaded, so no need to touch the DB lambda { student.publications_of_type(:magazine) }.should_not touch_the_database end end end So the test should fail in this example, because the rails 'find_all_by' method relies on SQL.

    Read the article

  • How would I rspec/test an updated_at field without using sleep() in ruby?

    - by Kamilski81
    How do i write my spec without using the sleep(1.second) method? When I remove the sleep then my tests break because they are returning the same time stamp? I have the following class method: def skip qs = find_or_create_by(user_id: user_id) qs.set_updated_at qs.n_skip += 1 qs.save! end and following spec: qs = skip(user.id) sleep(1.second) qs2 = skip(user.id) qs.should_not be_nil qs2.should_not be_nil (qs.updated_at < qs2.updated_at).should be_true

    Read the article

  • In rails, what defines unit testing as opposed to other kinds of testing

    - by junky
    Initially I thought this was simple: unit testing for models with other testing such as integration for controller and browser testing for views. But more recently I've seen a lot of references to unit testing that doesn't seem to exactly follow this format. Is it possible to have a unit test of a controller? Does that mean that just one method is called? What's the distinction? What does unit testing really means in my rails world?

    Read the article

  • Rails test db doesn't persist record changes

    - by nathan.f77
    I've been trying to solve a problem for a few weeks now. I am running rspec tests for my Rails app, and they are working fine except for one error that I can't seem get my head around. I am using MySQL with the InnoDB engine. I have set config.use_transactional_fixtures = true in spec_helper.rb I load my test fixtures manually with the command rake spec:db:fixtures:load. The rspec test is being written for a BackgrounDRb worker, and it is testing that a record can have its state updated (through the state_machine gem). Here is my problem: I have a model called Listings. The rspec test calls the update_sold_items method within a file called listing_worker.rb. This method calls listing.sell for a particular record, which sets the listing record's 'state' column to 'sold'. So far, this is all working fine, but when the update_sold_items method finishes, my rspec test fails here: listing = Listing.find_by_listing_id(listing_id) listing.state.should == "sold" expected: "sold", got: "current" (using ==) I've been trying to track down why the state change is not persisting, but am pretty much lost. Here is the result of some debugging code that I placed in the update_sold_items method during the test: pp listing.state # => "current" listing.sell! listing.save! pp listing.state # => "sold" listing.reload pp listing.state # => "current" I cannot understand why it saves perfectly fine, but then reverts back to the original record whenever I call reload, or Listing.find etc. Thanks for reading this, and please ask any questions if I haven't given enough information. Thanks for your help, Nathan B P.S. I don't have a problem creating new records for other classes, and testing those records. It only seems to be a problem when I am updating records that already exist in the database.

    Read the article

  • uninitialized constant Test::Unit::TestResult::TestResultFailureSupport

    - by Vitaly Kushner
    I get the error in subj when I'm trying to run specs or generators in a fresh rails project. This happens when I add shoulda to the mix. I added the following in the config/environment.rb: config.gem 'rspec', :version => '1.2.6', :lib => false config.gem 'rspec-rails', :version => '1.2.6', :lib => false config.gem "thoughtbot-shoulda", :version => "2.10.2", :lib => 'shoulda', :source => "http://gems.github.com" I'm on OSX. ruby 1.8.6 (2008-08-11 patchlevel 287) gems 1.3.5 rails 2.3.4 rspec - 1.2.6 shoulda - 2.10.2 test-unit - 2.0.3 I'm aware of this and adding config.gem 'test-unit', :lib => 'test/unit' indeed solves the genrator problem as it doesn't throw an exception, but it prints 0 tests, 0 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications at the end of the run so I suppose it tries to run tests which is unexpected and undesired, also the specs stop to run at all, seems like rspec is not running at all, when running rake spec I get the test-unit output again (with 0 tests as there are only specs, no tests defined)

    Read the article

  • Textmate RSpec Run Example fails

    - by Barb
    When I try to run an RSpec example from within Textmate. I get "Rails requires RubyGems = 1.3.2 (you have 1.3.1). Please gem update --system and try again." I run gem update and I get nothing to update. I think the RSpec bundle is running from the built in directories rather than /local/. How do I change where the bundle looks? Thanks! :)

    Read the article

  • How do I write a spec to verify the rendering of partials?

    - by TheDeeno
    I'm using rr and rspec. Also, I'm using the collection short hand for partial rendering. My question: How do I correctly fill out the the following spec? before(:each) do assigns[:models] = Array.new(10, stub(Model)) end it "should render the 'listing' partial for each model" do # help me write something that actually verifies this end I've tried a few examples from the rspec book, rspec docs, and rr docs. Everything I try seems to leave me with runtime errors in the test - not failed assertions. Rather than show all the transformations I've tried, I figured all I'd need if someone showed me one that actually worked. I'd be good to go from there.

    Read the article

  • Using rspec to check creation of template

    - by Brian
    I am trying to use rspec with puppet to check the generation of a configuration file from an .erb file. However, I get the error 1) customizations should generate valid logstash.conf Failure/Error: content = catalogue.resource('file', 'logstash.conf').send(:parameters)[:content] ArgumentError: wrong number of arguments (0 for 1) # ./spec/classes/logstash_spec.rb:29:in `catalogue' # ./spec/classes/logstash_spec.rb:29 And the logstash_spec.rb: describe "customizations" do let(:params) { {:template => "profiles/logstash/output_broker.erb", :options => {'opt_a' => 'value_a' } } } it 'should generate valid logstash.conf' do content = catalogue.resource('file', 'logstash.conf').send(:parameters)[:content] content.should match('logstash') end end

    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

  • Errno::EACCES: Permission denied - ./tmp/rspec_guard_result

    - by Evgeniy Gatsalov
    Trying settup rspec-guard-spork for learning app from http://ruby.railstutorial.org/ Using Ruby 2.0, Rails 4.0 on Windows7 ( I know :( ) When starting guard, get: 23:02:51 - ERROR - Guard::RSpec failed to achieve its <run_on_modifications>, exception was: > [#] Errno::EACCES: Permission denied - ./tmp/rspec_guard_result ... All gemfile, guardfile etc are edited according tutorial. Except 1) deleting win32console gem from gemfile because it turned console-out into a crap and raised an error. Permissions for a file is "F"(ull) for all cattegories: D:\WebDevelop\sample_appcacls tmp\rspec_guard_result D:\WebDevelop\sample_app\tmp\rspec_guard_result BUILTIN\Users:(ID)F NT AUTHORITY\Authenticated:(ID)F BUILTIN\Administrators:(ID)F NT AUTHORITY\system:(ID)F What additional info should I provide here?

    Read the article

  • What is the best way to mock a 3rd party object in ruby?

    - by spinlock
    I'm writing a test app using the twitter gem and I'd like to write an integration test but I can't figure out how to mock the objects in the Twitter namespace. Here's the function that I want to test: def build_twitter(omniauth) Twitter.configure do |config| config.consumer_key = TWITTER_KEY config.consumer_secret = TWITTER_SECRET config.oauth_token = omniauth['credentials']['token'] config.oauth_token_secret = omniauth['credentials']['secret'] end client = Twitter::Client.new user = client.current_user self.name = user.name end and here's the rspec test that I'm trying to write: feature 'testing oauth' do before(:each) do @twitter = double("Twitter") @twitter.stub!(:configure).and_return true @client = double("Twitter::Client") @client.stub!(:current_user).and_return(@user) @user = double("Twitter::User") @user.stub!(:name).and_return("Tester") end scenario 'twitter' do visit root_path login_with_oauth page.should have_content("Pages#home") end end But, I'm getting this error: 1) testing oauth twitter Failure/Error: login_with_oauth Twitter::Error::Unauthorized: GET https://api.twitter.com/1/account/verify_credentials.json: 401: Invalid / expired Token # ./app/models/user.rb:40:in `build_twitter' # ./app/models/user.rb:16:in `build_authentication' # ./app/controllers/authentications_controller.rb:47:in `create' # ./spec/support/integration_spec_helper.rb:3:in `login_with_oauth' # ./spec/integration/twit_test.rb:16:in `block (2 levels) in <top (required)>' The mocks above are using rspec but I'm open to trying mocha too. Any help would be greatly appreciated.

    Read the article

  • Failing rspec Rails Tutorial Chapter 9.3

    - by greyghost24
    I am failing 3 tests and I have found numerous examples on here and on on the internet in general but I can't seem to find where I'm going wrong. Thanks for any help. 1) User pages signup with valid information edit page Failure/Error: before { visit edit_user_path(user) } ActionView::Template::Error: undefined method `model_name' for NilClass:Class # ./app/views/users/edit.html.erb:6:in `_app_views_users_edit_html_erb___4113112884365867193_70232486166220' # ./spec/requests/user_pages_spec.rb:96:in `block (5 levels) in <top (required)>' 2) User pages signup with valid information edit page Failure/Error: before { visit edit_user_path(user) } ActionView::Template::Error: undefined method `model_name' for NilClass:Class # ./app/views/users/edit.html.erb:6:in `_app_views_users_edit_html_erb___4113112884365867193_70232486166220' # ./spec/requests/user_pages_spec.rb:96:in `block (5 levels) in <top (required)>' 3) User pages signup with valid information edit page Failure/Error: before { visit edit_user_path(user) } ActionView::Template::Error: undefined method `model_name' for NilClass:Class # ./app/views/users/edit.html.erb:6:in `_app_views_users_edit_html_erb___4113112884365867193_70232486166220' # ./spec/requests/user_pages_spec.rb:96:in `block (5 levels) in <top (required)>' Finished in 0.26515 seconds 3 examples, 3 failures Failed examples: rspec ./spec/requests/user_pages_spec.rb:100 # User pages signup with valid information edit page rspec ./spec/requests/user_pages_spec.rb:99 # User pages signup with valid information edit page rspec ./spec/requests/user_pages_spec.rb:101 # User pages signup with valid information edit page authentication_pages_spec.rb require 'spec_helper' describe "Authentication" do subject { page } describe "signin page" do before { visit signin_path } it { should have_selector('h1', text: 'Sign in') } it { should have_selector('title', text: 'Sign in') } end describe "signin" do before { visit signin_path } describe "with invalid information" do before { click_button "Sign in" } it { should have_selector('title', text: 'Sign in') } it { should have_selector('div.alert.alert-error', text: 'Invalid') } describe "after visiting another page" do before { click_link "Home" } it { should_not have_selector('div.alert.alert-error') } end end describe "with valid information" do let(:user) { FactoryGirl.create(:user) } before do fill_in "Email", with: user.email fill_in "Password", with: user.password click_button "Sign in" end it { should have_selector('title', text: user.name) } it { should have_link('Profile', href: user_path(user)) } it { should have_link('Sign out', href: signout_path) } it { should_not have_link('Sign in', href: signin_path) } describe "followed by signout" do before { click_link "Sign out" } it { should have_link('Sign in') } end end end end Here is the users_controller: class UsersController < ApplicationController def show @user = User.find(params[:id]) end def new @user = User.new end def create @user = User.new(params[:user]) if @user.save sign_in @user flash[:success] = "Welcome to the Sample App!" redirect_to @user else render 'new' end end end def edit @user = User.find(params[:id]) end edit.html.erb: <% provide(:title, "Edit user") %> <h1>Update your profile</h1> <div class="row"> <div class="span6 offset3"> <%= form_for(@user) do |f| %> <%= render 'shared/error_messages' %> <%= f.label :name %> <%= f.text_field :name %> <%= f.label :email %> <%= f.text_field :email %> <%= f.label :password %> <%= f.password_field :password %> <%= f.label :password_confirmation, "Confirm Password" %> <%= f.password_field :password_confirmation %> <%= f.submit "Save changes", class: "btn btn-large btn-primary" %> <% end %> <%= gravatar_for @user %> <a href="http://gravatar.com/emails">change</a> </div> here is the user_pages_spec: require 'spec_helper' describe "User pages" do subject { page } describe "profile page" do let(:user) { FactoryGirl.create(:user) } before { visit user_path(user) } it { should have_selector('h1', text: user.name) } it { should have_selector('title', text: user.name) } end describe "signup page" do before { visit signup_path } it { should have_selector('h1', text: 'Sign up') } it { should have_selector('title', text: full_title('Sign up')) } end describe "signup" do before { visit signup_path } describe "with invalid information" do it "should not create a user" do expect { click_button "Create my account" }.not_to change(User, :count) end describe "error messages" do before { click_button "Create my account" } it { should have_selector('title', text: 'Sign up') } it { should have_content('error') } end end describe "with valid information" do before do fill_in "Name", with: "Example User" fill_in "Email", with: "[email protected]" fill_in "Password", with: "foobar" fill_in "Confirmation", with: "foobar" end it "should create a user" do expect do click_button "Create my account" end.to change(User, :count).by(1) end describe "after saving the user" do before { click_button "Create my account" } let(:user) { User.find_by_email('[email protected]') } it { should have_selector('title', text: user.name) } it { should have_selector('div.alert.alert-success', text: 'Welcome') } it { should have_link('Sign out') } end end end describe "signup page" do before { visit signup_path } it { should have_selector('h1', text: 'Sign up') } it { should have_selector('title', text: full_title('Sign up')) } end describe "signup" do before { visit signup_path } let(:submit) { "Create my account" } describe "with invalid information" do it "should not create a user" do expect { click_button submit }.not_to change(User, :count) end end describe "with valid information" do before do fill_in "Name", with: "Example User" fill_in "Email", with: "[email protected]" fill_in "Password", with: "foobar" fill_in "Confirmation", with: "foobar" end it "should create a user" do expect { click_button submit }.to change(User, :count).by(1) end describe "edit" do let(:user) { FactoryGirl.create(:user) } before { visit edit_user_path(user) } describe "page" do it { should have_selector('h1', text: "Update your profile") } it { should have_selector('title', text: "Edit user") } it { should have_link('change', href: 'http://gravatar.com/emails') } end describe "with invalid information" do before { click_button "Save changes" } it { should have_content('error') } end end end end end edit: users_controllers.rb was formatted incorrectly. It should look like this: class UsersController < ApplicationController def show @user = User.find(params[:id]) end def new @user = User.new end def create @user = User.new(params[:user]) if @user.save sign_in @user flash[:success] = "Welcome to the Sample App!" redirect_to @user else render 'new' end end def edit @user = User.find(params[:id]) end end

    Read the article

  • Why the cucumber features keeps running even though it fails?

    - by Millisami
    Its a rails 2.3.5 app. I'm using the rspec and cucumber for testing. When I run autospec, it runs correctly with the warning (Not running features. To run features in autotest, set AUTOFEATURE=true.) as below: [~/rails_apps/automation (campaign)?] ? autospec (Not running features. To run features in autotest, set AUTOFEATURE=true.) (Not running features. To run features in autotest, set AUTOFEATURE=true.) loading autotest/rails_rspec /home/millisami/.rvm/rubies/ree-1.8.7-2010.01/lib/ruby/1.8/pathname.rb:263: warning: `*' interpreted as argument prefix /home/millisami/.rvm/rubies/ree-1.8.7-2010.01/bin/ruby /home/millisami/.rvm/gems/ree-1.8.7-2010.01/gems/rspec-1.3.0/bin/spec --autospec /home/millisami/rails_apps/automation/spec/controllers/campaigns_controller_spec.rb /home/millisami/rails_apps/automation/spec/models/board_spec.rb /home/millisami/rails_apps/automation/spec/models/user_spec.rb /home/millisami/rails_apps/automation/spec/models/campaign_spec.rb /home/millisami/rails_apps/automation/spec/controllers/outlets_controller_spec.rb /home/millisami/rails_apps/automation/spec/controllers/boards_controller_spec.rb /home/millisami/rails_apps/automation/spec/models/outlet_type_spec.rb /home/millisami/rails_apps/automation/spec/models/vendor_spec.rb /home/millisami/rails_apps/automation/spec/controllers/brands_controller_spec.rb /home/millisami/rails_apps/automation/spec/controllers/vendors_controller_spec.rb /home/millisami/rails_apps/automation/spec/controllers/dashboard_controller_spec.rb /home/millisami/rails_apps/automation/spec/models/brand_spec.rb /home/millisami/rails_apps/automation/spec/helpers/dashboard_helper_spec.rb /home/millisami/rails_apps/automation/spec/models/outlet_spec.rb /home/millisami/rails_apps/automation/spec/models/client_spec.rb /home/millisami/rails_apps/automation/spec/controllers/clients_controller_spec.rb -O spec/spec.opts Now, as it suggests, when I run AUTOFEATURE=true autospec, the specs runs and the cuke features as well. But the problem is that it won't stop. It runs the features and runs them again and again in a loop. It doesn't stop after it fails. Is this due to the warning Warning: $KCODE is NONE as shown below?? [~/rails_apps/automation (campaign)?] ? AUTOFEATURE=true autospec loading autotest/cucumber_rails_rspec Warning: $KCODE is NONE. /home/millisami/.rvm/gems/ree-1.8.7-2010.01/gems/treetop-1.4.5/lib/treetop/ruby_extensions/string.rb:31: warning: method redefined; discarding old indent /home/millisami/.rvm/rubies/ree-1.8.7-2010.01/lib/ruby/1.8/pathname.rb:263: warning: `*' interpreted as argument prefix /home/millisami/.rvm/gems/ree-1.8.7-2010.01/gems/activesupport-2.3.5/lib/active_support/core_ext/object/blank.rb:49: warning: method redefined; discarding old blank? /home/millisami/.rvm/rubies/ree-1.8.7-2010.01/bin/ruby /home/millisami/.rvm/gems/ree-1.8.7-2010.01/gems/rspec-1.3.0/bin/spec --autospec /home/millisami/rails_apps/automation/spec/controllers/campaigns_controller_spec.rb /home/millisami/rails_apps/automation/spec/models/board_spec.rb /home/millisami/rails_apps/automation/spec/models/user_spec.rb /home/millisami/rails_apps/automation/spec/models/campaign_spec.rb /home/millisami/rails_apps/automation/spec/controllers/outlets_controller_spec.rb /home/millisami/rails_apps/automation/spec/controllers/boards_controller_spec.rb /home/millisami/rails_apps/automation/spec/models/outlet_type_spec.rb /home/millisami/rails_apps/automation/spec/models/vendor_spec.rb /home/millisami/rails_apps/automation/spec/controllers/brands_controller_spec.rb /home/millisami/rails_apps/automation/spec/controllers/vendors_controller_spec.rb /home/millisami/rails_apps/automation/spec/controllers/dashboard_controller_spec.rb /home/millisami/rails_apps/automation/spec/models/brand_spec.rb /home/millisami/rails_apps/automation/spec/helpers/dashboard_helper_spec.rb /home/millisami/rails_apps/automation/spec/models/outlet_spec.rb /home/millisami/rails_apps/automation/spec/models/client_spec.rb /home/millisami/rails_apps/automation/spec/controllers/clients_controller_spec.rb -O spec/spec.opts

    Read the article

  • Setting up autotest with rspec in ubuntu

    - by Reactor5
    I'm trying to set up autotest on Ubuntu, and no matter what my configuration, I get this: loading autotest/rails_rspec2 style: RailsRspec2 /home/brian/.rvm/gems/ruby-1.9.2-rc2@rails3tutorial/gems/redgreen-1.2.2/lib/redgreen/autotest.rb:6:in `<top (required)>': uninitialized constant Object::PLATFORM (NameError) the .autotest (~/.autotest) file I have is as follows: #!/usr/bin/env ruby require 'redgreen/autotest' def self.notify title, msg, img, pri='low', time=3000 `notify-send -i #{img} -u #{pri} -t #{time} '#{msg}'` end Autotest.add_hook :ran_command do |at| results = [at.results].flatten.join("\n") output = results.slice(/(\d+)\s+examples?,\s*(\d+)\s+failures?(,\s*(\d+)\s+not implemented)?(,\s*(\d+)\s+pending)?/) folder = "~/Pictures/autotest/" if output =~ /([123456789]|[\d]{2,})\sfailures?/ notify "FAIL:", "#{output}", folder+"rails_fail.png", 'critical', 10000 elsif output =~ /[1-9]\d*\spending?/ notify "PENDING:", "#{output}", folder+"rails_pending.png", 'normal', 10000 else notify "PASS:", "#{output}", folder+"rails_ok.png" end end what am I doing wrong here?

    Read the article

  • Session variables with Cucumber Stories

    - by Matthew Savage
    I am working on some Cucumber stories for a 'sign up' application which has a number of steps. Rather then writing a Huuuuuuuge story to cover all the steps at once, which would be bad, I'd rather work through each action in the controller like a regular user. My problem here is that I am storing the account ID which is created in the first step as a session variable, so when step 2, step 3 etc are visited the existing registration data is loaded. I'm aware of being able to access controller.session[..] within RSpec specifications however when I try to do this in Cucumber stories it fails with the following error (and, I've also read somewhere this is an anti-pattern etc...): Using controller.session[:whatever] or session[:whatever] You have a nil object when you didn't expect it! The error occurred while evaluating nil.session (NoMethodError) Using session(:whatever) wrong number of arguments (1 for 0) (ArgumentError) So, it seems accession the session store isn't really possible. What I'm wondering is if it might be possible to (and I guess which would be best..): Mock out the session store etc Have a method within the controller and stub that out (e.g. get_registration which assigns an instance variable...) I've looked through the RSpec book (well, skimmed) and had a look through WebRat etc, but I haven't really found an answer to my problem... To clarify a bit more, the signup process is more like a state machine - e.g. the user progresses through four steps before the registration is complete - hence 'logging in' isn't really an option (it breaks the model of how the site works)... In my spec for the controller I was able to stub out the call to the method which loads the model based on the session var - but I'm not sure if the 'antipattern' line also applies to stubs as well as mocks? Thanks!

    Read the article

  • What is the subject of Rspecs its method

    - by Steve Weet
    When you use the its method in rspec like follows its(:code) { should eql(0)} what is 'its' referring to. I have the following spec that works fine describe AdminlwController do shared_examples_for "valid status" do it { should be_an_instance_of(Api::SoapStatus) } it "should have a code of 0" do subject.code.should eql(0) end it "should have an empty errors array" do subject.errors.should be_an(Array) subject.errors.should be_empty end #its(:code) { should eql(0)} end describe "Countries API Reply" do before :each do co1 = Factory(:country) co2 = Factory(:country) @result = invoke :GetCountryList, "empty_auth" end subject { @result } it { should be_an_instance_of(Api::GetCountryListReply) } describe "Country List" do subject {@result.country_list} it { should be_an_instance_of(Array) } it { should have(2).items } it "should have countries in the list" do subject.each {|c| c.should be_an_instance_of(Api::Country)} end end describe "result status" do subject { @result.status } it_should_behave_like "valid status" end end However if I then uncomment the line with its(:code) then I get the following output AdminlwController Countries API Reply - should be an instance of Api::GetCountryListReply AdminlwController Countries API Reply Country List - should be an instance of Array - should have 2 items - should have countries in the list AdminlwController Countries API Reply result status - should be an instance of Api::SoapStatus - should have a code of 0 - should have an empty errors array AdminlwController Countries API Reply result status code - should be empty (FAILED - 1) 1) NoMethodError in 'AdminlwController Countries API Reply result status code should be empty' undefined method code for <AdminlwController:0x40fc4dc> /Users/steveweet/romad_current/romad/spec/controllers/adminlw_controller_spec.rb:29: Finished in 0.741599 seconds 8 examples, 1 failure It seems as if "its" is referring to the subject of the whole test, namely AdminLwController rather than the current subject. Am I doing something wrong or is this an Rspec oddity?

    Read the article

  • Spork doesnt reload code

    - by there-is-no-spoon
    I am using following gems and ruby-1.9.3-p194: rails 3.2.3 rspec-rails 2.9.0 spork 1.0.0rc2 guard-spork 0.6.1 Full list of used gems is available in this Gemfile.lock or Gemfile. And I am using this configuration files: Guardfile .rspec spec_helper.rb factories.rb If I modify any model (or custom validator in app/validators etc) reloading code doesnt works. I mean when I run specs (hit Enter on guard console) Spork contain "old code" and I got obsolete error messages. But when I manually restart Guard and Spork (CTRC-C CTRL-d guard) everything works fine. But it is getting tired after few times. Questions: Can somebody look at my config files please and fix error which block updating code. Or maybe this is an issue of newest Rails version? PS This problem repeats and repeats over some projects (and on some NOT). But I haven't figured out yet why this is happens. PS2 Perhaps this problem is something to do with ActiveAdmin? When I change file in app/admin code is reloaded.

    Read the article

  • Test for absence of an input tag's value attribute

    - by Jeff
    How can I confirm the absence of a HTML attribute in a Rails RSpec test? I can verify that an input tag has a value attribute and that it is an empty string like so: response.should have_tag("input[name=?][value=?]", "user[password]", "") response.should have_tag("input[name=?][value=?]", "user[password_confirmation]", "") But what I want to do is verify that my input fields do not have a value attribute at all (i.e., a blank field).

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11  | Next Page >