Skip to content

Commit

Permalink
Rspec 3 syntax + require rspec >=3
Browse files Browse the repository at this point in the history
  • Loading branch information
johnae committed Oct 3, 2014
1 parent 216f8c9 commit 8def049
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion role_playing.gemspec
Expand Up @@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.require_paths = ["lib"]

gem.add_development_dependency("rspec", ">= 2.12.0")
gem.add_development_dependency("rspec", ">= 3.0")
gem.add_development_dependency("bundler")

gem.add_dependency("activesupport", ">= 3.0.0")
Expand Down
42 changes: 21 additions & 21 deletions spec/role_playing/role_playing_spec.rb
Expand Up @@ -59,30 +59,30 @@ def deposit(amount)
subject { MyRole.new(bare_object) }

it "should be of same class as wrapped object" do
subject.class.should == bare_object.class
expect(subject.class).to eq bare_object.class
end

it "should be equal to wrapped object" do
subject.should == bare_object
expect(subject).to eq bare_object
end

it "should respond_to additional methods" do
subject.should respond_to(:two_fields)
expect(subject).to respond_to(:two_fields)
end

it "#two_fields should concatenate data objects two fields" do
subject.two_fields.should == "#{bare_object.field_1} #{bare_object.field_2}"
expect(subject.two_fields).to eq "#{bare_object.field_1} #{bare_object.field_2}"
end

it "#role_player should not respond_to additional methods" do
subject.role_player.should_not respond_to(:two_fields)
expect(subject.role_player).to_not respond_to(:two_fields)
end

it "#in_role takes a block and returns the result" do
two_fields = MyRole.played_by(bare_object) do |role|
role.two_fields
end
two_fields.should == "#{bare_object.field_1} #{bare_object.field_2}"
expect(two_fields).to eq "#{bare_object.field_1} #{bare_object.field_2}"
end

end
Expand All @@ -109,9 +109,9 @@ def base

it "an array of roles can be applied using Array#played_by" do
role = [role_class_1, role_class_2].played_by(player_class.new)
role.should respond_to(:role_1)
role.should respond_to(:role_2)
role.should respond_to(:base)
expect(role).to respond_to(:role_1)
expect(role).to respond_to(:role_2)
expect(role).to respond_to(:base)
end
end

Expand All @@ -122,13 +122,13 @@ def base
let(:bare_account) {Account.new(original_amount)}
subject { MoneyTransferring::SourceAccount.new(bare_account) }
it "adds a withdraw method to data object" do
bare_account.should_not respond_to(:withdraw)
subject.should respond_to(:withdraw)
expect(bare_account).to_not respond_to(:withdraw)
expect(subject).to respond_to(:withdraw)
end
it "withdraws a specified amount" do
subject.withdraw(10)
subject.amount.should == original_amount-10
bare_account.amount.should == original_amount-10
expect(subject.amount).to eq original_amount-10
expect(bare_account.amount).to eq original_amount-10
end
end

Expand All @@ -137,13 +137,13 @@ def base
let(:bare_account) {Account.new(original_amount)}
subject { MoneyTransferring::DestinationAccount.new(bare_account) }
it "adds a deposit method to data object" do
bare_account.should_not respond_to(:deposit)
subject.should respond_to(:deposit)
expect(bare_account).to_not respond_to(:deposit)
expect(subject).to respond_to(:deposit)
end
it "deposits a specified amount" do
subject.deposit(10)
subject.amount.should == original_amount+10
bare_account.amount.should == original_amount+10
expect(subject.amount).to eq original_amount+10
expect(bare_account.amount).to eq original_amount+10
end
end

Expand All @@ -155,11 +155,11 @@ def base
subject { MoneyTransferring.new(source_account, destination_account) }

it "transfers a specified amount from a SourceAccount to a DestinationAccount" do
source_account.amount.should == original_source_account_amount
destination_account.amount.should == original_destination_account_amount
expect(source_account.amount).to eq original_source_account_amount
expect(destination_account.amount).to eq original_destination_account_amount
subject.call(transfer_amount)
source_account.amount.should == original_source_account_amount-transfer_amount
destination_account.amount.should == original_destination_account_amount+transfer_amount
expect(source_account.amount).to eq original_source_account_amount-transfer_amount
expect(destination_account.amount).to eq original_destination_account_amount+transfer_amount
end

end
Expand Down

0 comments on commit 8def049

Please sign in to comment.