Skip to content

Commit

Permalink
update test to test only the block param
Browse files Browse the repository at this point in the history
  • Loading branch information
formigarafa committed Jan 15, 2017
1 parent 3da8bcc commit 66d5b5d
Showing 1 changed file with 7 additions and 6 deletions.
Expand Up @@ -104,18 +104,19 @@
expect(actual_sql).to eq expected_sql
end

it 'executes the block in the context of an empty scope parametrised by association source' do
it 'pass instance of association source to block' do
spy = spy('spy')
define_model(:country, mood: :string)
person_model = define_model(:person, country_id: :integer, spirit: :string) do
belongs_to :country, -> (person) { where(mood: person.spirit) }
person_model = define_model(:person, country_id: :integer) do
belongs_to :country, ->(person) { spy.who(person) }
end
person_instance = person_model.new(spirit: 'nice')
delegate_reflection = person_model.reflect_on_association(:country)
reflection = described_class.new(delegate_reflection)

actual_sql = reflection.association_relation(person_instance).to_sql
expected_sql = Country.where(mood: 'nice').to_sql
expect(actual_sql).to eq expected_sql
reflection.association_relation(person_instance)

expect(spy).to have_received(:who).with(person_instance)
end
end

Expand Down

0 comments on commit 66d5b5d

Please sign in to comment.