mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-21 09:40:13 +01:00
Added Rspec and Webrat plugins and started porting Selenium on Rails tests to Rspec Plain Text Stories driving Webrat driving Selenium.
This commit is contained in:
parent
0600756bbf
commit
0f7d6f7a1d
602 changed files with 47788 additions and 29 deletions
7
vendor/plugins/rspec/failing_examples/README.txt
vendored
Normal file
7
vendor/plugins/rspec/failing_examples/README.txt
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
"Why have failing examples?", you might ask.
|
||||
|
||||
They allow us to see failure messages. RSpec wants to provide meaningful and helpful failure messages. The failures in this directory not only provide you a way of seeing the failure messages, but they provide RSpec's own specs a way of describing what they should look like and ensuring they stay correct.
|
||||
|
||||
To see the types of messages you can expect, stand in this directory and run:
|
||||
|
||||
../bin/spec ./*.rb
|
||||
36
vendor/plugins/rspec/failing_examples/diffing_spec.rb
vendored
Normal file
36
vendor/plugins/rspec/failing_examples/diffing_spec.rb
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
describe "Running specs with --diff" do
|
||||
it "should print diff of different strings" do
|
||||
uk = <<-EOF
|
||||
RSpec is a
|
||||
behaviour driven development
|
||||
framework for Ruby
|
||||
EOF
|
||||
usa = <<-EOF
|
||||
RSpec is a
|
||||
behavior driven development
|
||||
framework for Ruby
|
||||
EOF
|
||||
usa.should == uk
|
||||
end
|
||||
|
||||
class Animal
|
||||
def initialize(name,species)
|
||||
@name,@species = name,species
|
||||
end
|
||||
|
||||
def inspect
|
||||
<<-EOA
|
||||
<Animal
|
||||
name=#{@name},
|
||||
species=#{@species}
|
||||
>
|
||||
EOA
|
||||
end
|
||||
end
|
||||
|
||||
it "should print diff of different objects' pretty representation" do
|
||||
expected = Animal.new "bob", "giraffe"
|
||||
actual = Animal.new "bob", "tortoise"
|
||||
expected.should eql(actual)
|
||||
end
|
||||
end
|
||||
19
vendor/plugins/rspec/failing_examples/failing_autogenerated_docstrings_example.rb
vendored
Normal file
19
vendor/plugins/rspec/failing_examples/failing_autogenerated_docstrings_example.rb
vendored
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
require File.dirname(__FILE__) + '/spec_helper'
|
||||
|
||||
# Run spec w/ -fs to see the output of this file
|
||||
|
||||
describe "Failing examples with no descriptions" do
|
||||
|
||||
# description is auto-generated as "should equal(5)" based on the last #should
|
||||
it do
|
||||
3.should equal(2)
|
||||
5.should equal(5)
|
||||
end
|
||||
|
||||
it { 3.should be > 5 }
|
||||
|
||||
it { ["a"].should include("b") }
|
||||
|
||||
it { [1,2,3].should_not respond_to(:size) }
|
||||
|
||||
end
|
||||
10
vendor/plugins/rspec/failing_examples/failure_in_setup.rb
vendored
Normal file
10
vendor/plugins/rspec/failing_examples/failure_in_setup.rb
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
describe "This example" do
|
||||
|
||||
before(:each) do
|
||||
NonExistentClass.new
|
||||
end
|
||||
|
||||
it "should be listed as failing in setup" do
|
||||
end
|
||||
|
||||
end
|
||||
10
vendor/plugins/rspec/failing_examples/failure_in_teardown.rb
vendored
Normal file
10
vendor/plugins/rspec/failing_examples/failure_in_teardown.rb
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
describe "This example" do
|
||||
|
||||
it "should be listed as failing in teardown" do
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
NonExistentClass.new
|
||||
end
|
||||
|
||||
end
|
||||
40
vendor/plugins/rspec/failing_examples/mocking_example.rb
vendored
Normal file
40
vendor/plugins/rspec/failing_examples/mocking_example.rb
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
require File.dirname(__FILE__) + '/spec_helper'
|
||||
|
||||
describe "Mocker" do
|
||||
|
||||
it "should be able to call mock()" do
|
||||
mock = mock("poke me")
|
||||
mock.should_receive(:poke)
|
||||
mock.poke
|
||||
end
|
||||
|
||||
it "should fail when expected message not received" do
|
||||
mock = mock("poke me")
|
||||
mock.should_receive(:poke)
|
||||
end
|
||||
|
||||
it "should fail when messages are received out of order" do
|
||||
mock = mock("one two three")
|
||||
mock.should_receive(:one).ordered
|
||||
mock.should_receive(:two).ordered
|
||||
mock.should_receive(:three).ordered
|
||||
mock.one
|
||||
mock.three
|
||||
mock.two
|
||||
end
|
||||
|
||||
it "should get yelled at when sending unexpected messages" do
|
||||
mock = mock("don't talk to me")
|
||||
mock.should_not_receive(:any_message_at_all)
|
||||
mock.any_message_at_all
|
||||
end
|
||||
|
||||
it "has a bug we need to fix" do
|
||||
pending "here is the bug" do
|
||||
# Actually, no. It's fixed. This will fail because it passes :-)
|
||||
mock = mock("Bug")
|
||||
mock.should_receive(:hello)
|
||||
mock.hello
|
||||
end
|
||||
end
|
||||
end
|
||||
26
vendor/plugins/rspec/failing_examples/mocking_with_flexmock.rb
vendored
Normal file
26
vendor/plugins/rspec/failing_examples/mocking_with_flexmock.rb
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# stub frameworks like to gum up Object, so this is deliberately
|
||||
# set NOT to run so that you don't accidentally run it when you
|
||||
# run this dir.
|
||||
|
||||
# To run it, stand in this directory and say:
|
||||
#
|
||||
# RUN_FLEXMOCK_EXAMPLE=true ruby ../bin/spec mocking_with_flexmock.rb
|
||||
|
||||
if ENV['RUN_FLEXMOCK_EXAMPLE']
|
||||
Spec::Runner.configure do |config|
|
||||
config.mock_with :flexmock
|
||||
end
|
||||
|
||||
describe "Flexmocks" do
|
||||
it "should fail when the expected message is received with wrong arguments" do
|
||||
m = flexmock("now flex!")
|
||||
m.should_receive(:msg).with("arg").once
|
||||
m.msg("other arg")
|
||||
end
|
||||
|
||||
it "should fail when the expected message is not received at all" do
|
||||
m = flexmock("now flex!")
|
||||
m.should_receive(:msg).with("arg").once
|
||||
end
|
||||
end
|
||||
end
|
||||
25
vendor/plugins/rspec/failing_examples/mocking_with_mocha.rb
vendored
Normal file
25
vendor/plugins/rspec/failing_examples/mocking_with_mocha.rb
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# stub frameworks like to gum up Object, so this is deliberately
|
||||
# set NOT to run so that you don't accidentally run it when you
|
||||
# run this dir.
|
||||
|
||||
# To run it, stand in this directory and say:
|
||||
#
|
||||
# RUN_MOCHA_EXAMPLE=true ruby ../bin/spec mocking_with_mocha.rb
|
||||
|
||||
if ENV['RUN_MOCHA_EXAMPLE']
|
||||
Spec::Runner.configure do |config|
|
||||
config.mock_with :mocha
|
||||
end
|
||||
describe "Mocha framework" do
|
||||
it "should should be made available by saying config.mock_with :mocha" do
|
||||
m = mock()
|
||||
m.expects(:msg).with("arg")
|
||||
m.msg
|
||||
end
|
||||
it "should should be made available by saying config.mock_with :mocha" do
|
||||
o = Object.new
|
||||
o.expects(:msg).with("arg")
|
||||
o.msg
|
||||
end
|
||||
end
|
||||
end
|
||||
27
vendor/plugins/rspec/failing_examples/mocking_with_rr.rb
vendored
Normal file
27
vendor/plugins/rspec/failing_examples/mocking_with_rr.rb
vendored
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# stub frameworks like to gum up Object, so this is deliberately
|
||||
# set NOT to run so that you don't accidentally run it when you
|
||||
# run this dir.
|
||||
|
||||
# To run it, stand in this directory and say:
|
||||
#
|
||||
# RUN_RR_EXAMPLE=true ruby ../bin/spec mocking_with_rr.rb
|
||||
|
||||
if ENV['RUN_RR_EXAMPLE']
|
||||
Spec::Runner.configure do |config|
|
||||
config.mock_with :rr
|
||||
end
|
||||
describe "RR framework" do
|
||||
it "should should be made available by saying config.mock_with :rr" do
|
||||
o = Object.new
|
||||
mock(o).msg("arg")
|
||||
o.msg
|
||||
end
|
||||
it "should should be made available by saying config.mock_with :rr" do
|
||||
o = Object.new
|
||||
mock(o) do |m|
|
||||
m.msg("arg")
|
||||
end
|
||||
o.msg
|
||||
end
|
||||
end
|
||||
end
|
||||
20
vendor/plugins/rspec/failing_examples/partial_mock_example.rb
vendored
Normal file
20
vendor/plugins/rspec/failing_examples/partial_mock_example.rb
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
require File.dirname(__FILE__) + '/spec_helper'
|
||||
|
||||
class MockableClass
|
||||
def self.find id
|
||||
return :original_return
|
||||
end
|
||||
end
|
||||
|
||||
describe "A partial mock" do
|
||||
|
||||
it "should work at the class level (but fail here due to the type mismatch)" do
|
||||
MockableClass.should_receive(:find).with(1).and_return {:stub_return}
|
||||
MockableClass.find("1").should equal(:stub_return)
|
||||
end
|
||||
|
||||
it "should revert to the original after each spec" do
|
||||
MockableClass.find(1).should equal(:original_return)
|
||||
end
|
||||
|
||||
end
|
||||
29
vendor/plugins/rspec/failing_examples/predicate_example.rb
vendored
Normal file
29
vendor/plugins/rspec/failing_examples/predicate_example.rb
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
require File.dirname(__FILE__) + '/spec_helper'
|
||||
|
||||
class BddFramework
|
||||
def intuitive?
|
||||
true
|
||||
end
|
||||
|
||||
def adopted_quickly?
|
||||
#this will cause failures because it reallly SHOULD be adopted quickly
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
describe "BDD framework" do
|
||||
|
||||
before(:each) do
|
||||
@bdd_framework = BddFramework.new
|
||||
end
|
||||
|
||||
it "should be adopted quickly" do
|
||||
#this will fail because it reallly SHOULD be adopted quickly
|
||||
@bdd_framework.should be_adopted_quickly
|
||||
end
|
||||
|
||||
it "should be intuitive" do
|
||||
@bdd_framework.should be_intuitive
|
||||
end
|
||||
|
||||
end
|
||||
47
vendor/plugins/rspec/failing_examples/raising_example.rb
vendored
Normal file
47
vendor/plugins/rspec/failing_examples/raising_example.rb
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
describe "This example" do
|
||||
|
||||
it "should show that a NoMethodError is raised but an Exception was expected" do
|
||||
proc { ''.nonexistent_method }.should raise_error
|
||||
end
|
||||
|
||||
it "should pass" do
|
||||
proc { ''.nonexistent_method }.should raise_error(NoMethodError)
|
||||
end
|
||||
|
||||
it "should show that a NoMethodError is raised but a SyntaxError was expected" do
|
||||
proc { ''.nonexistent_method }.should raise_error(SyntaxError)
|
||||
end
|
||||
|
||||
it "should show that nothing is raised when SyntaxError was expected" do
|
||||
proc { }.should raise_error(SyntaxError)
|
||||
end
|
||||
|
||||
it "should show that a NoMethodError is raised but a Exception was expected" do
|
||||
proc { ''.nonexistent_method }.should_not raise_error
|
||||
end
|
||||
|
||||
it "should show that a NoMethodError is raised" do
|
||||
proc { ''.nonexistent_method }.should_not raise_error(NoMethodError)
|
||||
end
|
||||
|
||||
it "should also pass" do
|
||||
proc { ''.nonexistent_method }.should_not raise_error(SyntaxError)
|
||||
end
|
||||
|
||||
it "should show that a NoMethodError is raised when nothing expected" do
|
||||
proc { ''.nonexistent_method }.should_not raise_error(Exception)
|
||||
end
|
||||
|
||||
it "should show that the wrong message was received" do
|
||||
proc { raise StandardError.new("what is an enterprise?") }.should raise_error(StandardError, "not this")
|
||||
end
|
||||
|
||||
it "should show that the unexpected error/message was thrown" do
|
||||
proc { raise StandardError.new("abc") }.should_not raise_error(StandardError, "abc")
|
||||
end
|
||||
|
||||
it "should pass too" do
|
||||
proc { raise StandardError.new("abc") }.should_not raise_error(StandardError, "xyz")
|
||||
end
|
||||
|
||||
end
|
||||
3
vendor/plugins/rspec/failing_examples/spec_helper.rb
vendored
Normal file
3
vendor/plugins/rspec/failing_examples/spec_helper.rb
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
lib_path = File.expand_path("#{File.dirname(__FILE__)}/../lib")
|
||||
$LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
|
||||
require "spec"
|
||||
7
vendor/plugins/rspec/failing_examples/syntax_error_example.rb
vendored
Normal file
7
vendor/plugins/rspec/failing_examples/syntax_error_example.rb
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
describe "when passing a block to a matcher" do
|
||||
it "you should use {} instead of do/end" do
|
||||
Object.new.should satisfy do
|
||||
"this block is being passed to #should instead of #satisfy - use {} instead"
|
||||
end
|
||||
end
|
||||
end
|
||||
44
vendor/plugins/rspec/failing_examples/team_spec.rb
vendored
Normal file
44
vendor/plugins/rspec/failing_examples/team_spec.rb
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
require File.dirname(__FILE__) + '/spec_helper'
|
||||
|
||||
|
||||
class Team
|
||||
attr_reader :players
|
||||
def initialize
|
||||
@players = Players.new
|
||||
end
|
||||
end
|
||||
|
||||
class Players
|
||||
def initialize
|
||||
@players = []
|
||||
end
|
||||
def size
|
||||
@players.size
|
||||
end
|
||||
def include? player
|
||||
raise "player must be a string" unless player.is_a?(String)
|
||||
@players.include? player
|
||||
end
|
||||
end
|
||||
|
||||
describe "A new team" do
|
||||
|
||||
before(:each) do
|
||||
@team = Team.new
|
||||
end
|
||||
|
||||
it "should have 3 players (failing example)" do
|
||||
@team.should have(3).players
|
||||
end
|
||||
|
||||
it "should include some player (failing example)" do
|
||||
@team.players.should include("Some Player")
|
||||
end
|
||||
|
||||
it "should include 5 (failing example)" do
|
||||
@team.players.should include(5)
|
||||
end
|
||||
|
||||
it "should have no players"
|
||||
|
||||
end
|
||||
7
vendor/plugins/rspec/failing_examples/timeout_behaviour.rb
vendored
Normal file
7
vendor/plugins/rspec/failing_examples/timeout_behaviour.rb
vendored
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
require File.dirname(__FILE__) + '/spec_helper'
|
||||
|
||||
describe "Something really slow" do
|
||||
it "should be failed by RSpec when it takes longer than --timeout" do
|
||||
sleep(2)
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue