Sha256: 435f48095f90d287282bffe7e36e01221b791d27b2ed376b484ba47e61aa5e8f

Contents?: true

Size: 1.36 KB

Versions: 87

Compression:

Stored size: 1.36 KB

Contents

require 'test_helper'

class AssignToMatcherTest < ActionController::TestCase # :nodoc:

  context "a controller that assigns to an instance variable" do
    setup do
      @controller = build_response { @var = 'value' }
    end

    should "accept assigning to that variable" do
      assert_accepts assign_to(:var), @controller
    end

    should "accept assigning to that variable with the correct class" do
      assert_accepts assign_to(:var).with_kind_of(String), @controller
    end

    should "reject assigning to that variable with another class" do
      assert_rejects assign_to(:var).with_kind_of(Fixnum), @controller
    end

    should "accept assigning the correct value to that variable" do
      assert_accepts assign_to(:var).with('value'), @controller
    end

    should "reject assigning another value to that variable" do
      assert_rejects assign_to(:var).with('other'), @controller
    end

    should "reject assigning to another variable" do
      assert_rejects assign_to(:other), @controller
    end

    should "accept assigning to the same value in the test context" do
      @expected = 'value'
      assert_accepts assign_to(:var).with { @expected }, @controller
    end

    should "reject assigning to the another value in the test context" do
      @expected = 'other'
      assert_rejects assign_to(:var).with { @expected }, @controller
    end
  end

end

Version data entries

87 entries across 57 versions & 8 rubygems

Version Path
challah-0.3.2 vendor/bundle/gems/shoulda-2.11.3/test/matchers/controller/assign_to_matcher_test.rb
challah-0.3.1 vendor/bundle/gems/shoulda-2.11.3/test/matchers/controller/assign_to_matcher_test.rb
challah-0.3.0 vendor/bundle/gems/shoulda-2.11.3/test/matchers/controller/assign_to_matcher_test.rb
challah-0.2.1 vendor/bundle/gems/shoulda-2.11.3/test/matchers/controller/assign_to_matcher_test.rb
challah-0.2.0 vendor/bundle/gems/shoulda-2.11.3/test/matchers/controller/assign_to_matcher_test.rb
chida_fib-0.1.0 shoulda/ruby/1.8/gems/shoulda-2.11.3/test/matchers/controller/assign_to_matcher_test.rb
dirty_history-0.4.10 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/controller/assign_to_matcher_test.rb
dirty_history-0.4.10 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/controller/assign_to_matcher_test.rb
dirty_history-0.4.10 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/controller/assign_to_matcher_test.rb
dirty_history-0.4.9 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/controller/assign_to_matcher_test.rb
dirty_history-0.4.9 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/controller/assign_to_matcher_test.rb
dirty_history-0.4.9 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/controller/assign_to_matcher_test.rb
dirty_history-0.4.8 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/controller/assign_to_matcher_test.rb
dirty_history-0.4.8 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/controller/assign_to_matcher_test.rb
dirty_history-0.4.8 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/controller/assign_to_matcher_test.rb
dirty_history-0.4.7 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/controller/assign_to_matcher_test.rb
dirty_history-0.4.7 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/controller/assign_to_matcher_test.rb
dirty_history-0.4.7 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/controller/assign_to_matcher_test.rb
dirty_history-0.4.6 dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/controller/assign_to_matcher_test.rb
dirty_history-0.4.6 dirty_history/ruby/1.9.1/gems/dirty_history-0.2.0/dirty_history/ruby/1.9.1/gems/shoulda-2.11.3/test/matchers/controller/assign_to_matcher_test.rb